home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / VertA11X.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  10.6 KB  |  348 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38. #ifdef FUNCTION_PTRS
  39.  
  40.   #define VERTEX_PTR_CALL (*vertexPtrCall)(vertexDim, type, stride, tmpVertexPtr);
  41.   #define NORMAL_PTR_CALL (*normalPtrCall)(type, stride, tmpNormalPtr);
  42.   #define COLOR_PTR_CALL (*colorPtrCall)(colorDim, type, stride, tmpColorPtr);
  43.   #define INDEX_PTR_CALL (*indexPtrCall)(type, stride, tmpIndexPtr);
  44.   #define TEX_PTR_CALL (*texPtrCall)(texDim, type, stride, tmpTexPtr);
  45.   #define INTERLEAVED_PTR_CALL (*interleavedPtrCall)(INTERLEAVED_FORMAT, stride, tmpInterleavedPtr);
  46.   #ifdef DRAW_ELEMENTS
  47.     #define DRAW_ARRAYS_CALL (*drawElementsCall)(mode, vertsPerBgnEnd, GL_UNSIGNED_INT, tmpElementsPtr);
  48.   #else
  49.     #define DRAW_ARRAYS_CALL (*drawArrayCall)(mode, first, vertsPerBgnEnd);
  50.   #endif
  51.   #ifdef LOCK_ARRAYS
  52.     #define LOCK_ARRAYS_CALL (*lockArrays)(0, vertsPerBgnEnd*numBgnEnds);
  53.     #define UNLOCK_ARRAYS_CALL (*unlockArrays)();
  54.   #else
  55.     #define LOCK_ARRAYS_CALL
  56.     #define UNLOCK_ARRAYS_CALL
  57.   #endif
  58.  
  59. #else
  60.  
  61.   #define VERTEX_PTR_CALL glVertexPointer(vertexDim, type, stride, tmpVertexPtr);
  62.   #define NORMAL_PTR_CALL glNormalPointer(type, stride, tmpNormalPtr);
  63.   #define COLOR_PTR_CALL glColorPointer(colorDim, type, stride, tmpColorPtr);
  64.   #define INDEX_PTR_CALL glIndexPointer(type, stride, tmpIndexPtr);
  65.   #define TEX_PTR_CALL glTexCoordPointer(texDim, type, stride, tmpTexPtr);
  66.   #define INTERLEAVED_PTR_CALL glInterleavedArrays(INTERLEAVED_FORMAT, stride, tmpInterleavedPtr);
  67.   #ifdef DRAW_ELEMENTS
  68.     #define DRAW_ARRAYS_CALL glDrawElements(mode, vertsPerBgnEnd, GL_UNSIGNED_INT, tmpElementsPtr);
  69.   #else
  70.     #define DRAW_ARRAYS_CALL glDrawArrays(mode, first, vertsPerBgnEnd);
  71.   #endif
  72.   #ifdef LOCK_ARRAYS
  73.     #define LOCK_ARRAYS_CALL glLockArraysSGI(0, vertsPerBgnEnd*numBgnEnds);
  74.     #define UNLOCK_ARRAYS_CALL glUnlockArraysSGI();
  75.   #else
  76.     #define LOCK_ARRAYS_CALL
  77.     #define UNLOCK_ARRAYS_CALL
  78.   #endif
  79.  
  80. #endif
  81.  
  82. #ifdef INTERLEAVED_DATA
  83.   #define VERTEX_PTR
  84.   #define SET_VERTEX_PTR
  85.   #define INCR_VERTEX_PTR
  86. #else
  87.   #define VERTEX_PTR VERTEX_PTR_CALL
  88.   #define SET_VERTEX_PTR tmpVertexPtr = vertexPtr;
  89.   #define INCR_VERTEX_PTR tmpVertexPtr += bgnendSize;
  90. #endif
  91.  
  92. #define DRAW_ARRAYS DRAW_ARRAYS_CALL
  93.  
  94. #ifdef NORMAL_DATA
  95.   #define NORMAL_PTR NORMAL_PTR_CALL
  96.   #define SET_NORMAL_PTR tmpNormalPtr = normalPtr;
  97.   #define INCR_NORMAL_PTR tmpNormalPtr += bgnendSize;
  98. #else
  99.   #define NORMAL_PTR
  100.   #define SET_NORMAL_PTR
  101.   #define INCR_NORMAL_PTR
  102. #endif
  103.  
  104. #ifdef COLOR_DATA
  105.   #define COLOR_PTR COLOR_PTR_CALL
  106.   #define SET_COLOR_PTR tmpColorPtr = colorPtr;
  107.   #define INCR_COLOR_PTR tmpColorPtr += bgnendSize;
  108. #else
  109.   #define COLOR_PTR
  110.   #define SET_COLOR_PTR
  111.   #define INCR_COLOR_PTR
  112. #endif
  113.  
  114. #ifdef INDEX_DATA
  115.   #define INDEX_PTR INDEX_PTR_CALL
  116.   #define SET_INDEX_PTR tmpIndexPtr = indexPtr;
  117.   #define INCR_INDEX_PTR tmpIndexPtr += bgnendSize;
  118. #else
  119.   #define INDEX_PTR
  120.   #define SET_INDEX_PTR
  121.   #define INCR_INDEX_PTR
  122. #endif
  123.  
  124. #ifdef TEX_DATA
  125.   #define TEX_PTR TEX_PTR_CALL
  126.   #define SET_TEX_PTR tmpTexPtr = texPtr;
  127.   #define INCR_TEX_PTR tmpTexPtr += bgnendSize;
  128. #else
  129.   #define TEX_PTR
  130.   #define SET_TEX_PTR
  131.   #define INCR_TEX_PTR
  132. #endif
  133.  
  134. #ifdef INTERLEAVED_DATA
  135.   #define INTERLEAVED_PTR INTERLEAVED_PTR_CALL
  136.   #define SET_INTERLEAVED_PTR tmpInterleavedPtr = interleavedPtr;
  137.   #define INCR_INTERLEAVED_PTR tmpInterleavedPtr += bgnendSize;
  138. #else
  139.   #define INTERLEAVED_PTR
  140.   #define SET_INTERLEAVED_PTR
  141.   #define INCR_INTERLEAVED_PTR
  142. #endif
  143.  
  144. #ifdef DRAW_ELEMENTS
  145.   #define INIT_ELEMENTS_PTR                         \
  146.     {                                    \
  147.     int numElements = numBgnEnds*vertsPerBgnEnd;            \
  148.     elementsPtr = (GLuint *)malloc(numElements*sizeof(GLuint));    \
  149.     for (i=0; i<numElements; i++) {                    \
  150.         elementsPtr[i] = i;                        \
  151.     }                                \
  152.     }
  153.   #define SET_ELEMENTS_PTR  tmpElementsPtr = elementsPtr;
  154.   #define INCR_ELEMENTS_PTR tmpElementsPtr += vertsPerBgnEnd;
  155.   #define FREE_ELEMENTS_PTR free(elementsPtr);
  156. #else
  157.   #define INIT_ELEMENTS_PTR
  158.   #define SET_ELEMENTS_PTR
  159.   #define INCR_ELEMENTS_PTR
  160.   #define FREE_ELEMENTS_PTR
  161. #endif
  162.  
  163. #define CALL_PTRS VERTEX_PTR \
  164.           NORMAL_PTR \
  165.           COLOR_PTR \
  166.           INDEX_PTR \
  167.           TEX_PTR \
  168.           INTERLEAVED_PTR
  169.  
  170. #define SET_PTRS SET_NORMAL_PTR \
  171.          SET_COLOR_PTR \
  172.          SET_INDEX_PTR \
  173.          SET_TEX_PTR \
  174.          SET_VERTEX_PTR \
  175.          SET_INTERLEAVED_PTR
  176.  
  177. #define INCR_PTRS INCR_NORMAL_PTR \
  178.           INCR_COLOR_PTR \
  179.           INCR_INDEX_PTR \
  180.           INCR_TEX_PTR \
  181.           INCR_VERTEX_PTR \
  182.           INCR_INTERLEAVED_PTR \
  183.           INCR_ELEMENTS_PTR
  184.  
  185. void FUNCTION (TestPtr thisTest)
  186. {
  187.     VertexPtr this = (VertexPtr)thisTest;
  188.     int i, j;
  189.     int iterations = this->iterations;
  190.     int numBgnEnds = this->numBgnEnds;
  191.     GLenum type = GL_FLOAT;
  192.     GLsizei vertsPerBgnEnd = this->vertsPerBgnEnd;
  193.     GLint first = 0;
  194.     GLint vertexDim = this->vertexDim;
  195.     GLsizei stride = this->vertexStride; 
  196.     GLsizei bgnendSize = this->bgnendSize; 
  197.     GLenum mode = this->primitiveType;
  198.  
  199. #ifndef INTERLEAVED_DATA
  200.     char* vertexPtr = this->vertexPtr; 
  201.     char* tmpVertexPtr;
  202. #endif
  203. #ifdef NORMAL_DATA
  204.     char* normalPtr = this->normalPtr;
  205.     char* tmpNormalPtr;
  206. #endif
  207. #ifdef COLOR_DATA
  208.     GLint colorDim = this->colorDim;
  209.     char* colorPtr = this->colorPtr;
  210.     char* tmpColorPtr;
  211. #endif
  212. #ifdef INDEX_DATA
  213.     char* indexPtr = this->indexPtr;
  214.     char* tmpIndexPtr;
  215. #endif
  216. #ifdef TEX_DATA
  217.     GLint texDim = this->texDim;
  218.     char* texPtr = this->texPtr;
  219.     char* tmpTexPtr;
  220. #endif
  221. #ifdef INTERLEAVED_DATA
  222.     char* interleavedPtr = this->colorPtr;
  223.     char* tmpInterleavedPtr;
  224. #endif
  225. #ifdef DRAW_ELEMENTS
  226.     GLuint* elementsPtr;
  227.     GLuint* tmpElementsPtr;
  228. #endif
  229.  
  230. #ifdef FUNCTION_PTRS
  231.   #ifdef WIN32
  232.       void (APIENTRY *vertexPtrCall)(GLint, GLenum, GLsizei, const void*) = glVertexPointer;
  233.     #ifdef NORMAL_DATA
  234.       void (APIENTRY *normalPtrCall)(GLenum, GLsizei, const void*) = glNormalPointer;
  235.     #endif
  236.     #ifdef COLOR_DATA
  237.       void (APIENTRY *colorPtrCall)(GLint, GLenum, GLsizei, const void*) = glColorPointer;
  238.     #endif
  239.     #ifdef INDEX_DATA
  240.       void (APIENTRY *indexPtrCall)(GLenum, GLsizei, const void*) = glIndexPointer;
  241.     #endif
  242.     #ifdef TEX_DATA
  243.       void (APIENTRY *texPtrCall)(GLint, GLenum, GLsizei, const void*) = glTexCoordPointer;
  244.     #endif
  245.     #ifdef INTERLEAVED_DATA
  246.       void (APIENTRY *interleavedPtrCall)(GLenum, GLsizei, const GLvoid *) = glInterleavedArrays;
  247.     #endif
  248.     #ifdef DRAW_ELEMENTS
  249.       void (APIENTRY *drawElementsCall)(GLenum, GLsizei, GLenum, const GLvoid *) = glDrawElements;
  250.     #else
  251.       void (APIENTRY *drawArrayCall)(GLenum, GLint, GLsizei) = glDrawArrays;
  252.     #endif
  253.     #ifdef LOCK_ARRAYS
  254.       void (APIENTRY *lockArrays)(GLint, GLsizei) = glLockArraysSGI;
  255.       void (APIENTRY *unlockArrays)(void) = glUnlockArraysSGI;
  256.     #endif
  257.   #else
  258.       void (*vertexPtrCall)(GLint, GLenum, GLsizei, const void*) = glVertexPointer;
  259.     #ifdef NORMAL_DATA
  260.       void (*normalPtrCall)(GLenum, GLsizei, const void*) = glNormalPointer;
  261.     #endif
  262.     #ifdef COLOR_DATA
  263.       void (*colorPtrCall)(GLint, GLenum, GLsizei, const void*) = glColorPointer;
  264.     #endif
  265.     #ifdef INDEX_DATA
  266.       void (*indexPtrCall)(GLenum, GLsizei, const void*) = glIndexPointer;
  267.     #endif
  268.     #ifdef TEX_DATA
  269.       void (*texPtrCall)(GLint, GLenum, GLsizei, const void*) = glTexCoordPointer;
  270.     #endif
  271.     #ifdef INTERLEAVED_DATA
  272.       void (*interleavedPtrCall)(GLenum, GLsizei, const GLvoid *) = glInterleavedArrays;
  273.     #endif
  274.     #ifdef DRAW_ELEMENTS
  275.       void (*drawElementsCall)(GLenum, GLsizei, GLenum, const GLvoid *) = glDrawElements;
  276.     #else
  277.       void (*drawArrayCall)(GLenum, GLint, GLsizei) = glDrawArrays;
  278.     #endif
  279.     #ifdef LOCK_ARRAYS
  280.       void (*lockArrays)(GLint, GLsizei) = glLockArraysSGI;
  281.       void (*unlockArrays)(void) = glUnlockArraysSGI;
  282.     #endif
  283.   #endif
  284. #endif
  285.  
  286. #ifdef DRAW_ELEMENTS
  287.     SET_PTRS
  288.     CALL_PTRS
  289.     INIT_ELEMENTS_PTR
  290.     for (i = iterations; i > 0; i--) {
  291.         SET_ELEMENTS_PTR
  292.     LOCK_ARRAYS_CALL
  293.     for (j = numBgnEnds; j > 0; j--) {
  294.         DRAW_ARRAYS
  295.         INCR_ELEMENTS_PTR
  296.     }
  297.     UNLOCK_ARRAYS_CALL
  298.     }
  299.     FREE_ELEMENTS_PTR
  300. #else
  301.     for (i = iterations; i > 0; i--) {
  302.     SET_PTRS
  303.     LOCK_ARRAYS_CALL
  304.     for (j = numBgnEnds; j > 0; j--) {
  305.         CALL_PTRS
  306.         DRAW_ARRAYS
  307.         INCR_PTRS
  308.     }
  309.     UNLOCK_ARRAYS_CALL
  310.     }
  311. #endif
  312. }
  313.  
  314. #undef VERTEX_PTR_CALL
  315. #undef NORMAL_PTR_CALL
  316. #undef COLOR_PTR_CALL
  317. #undef INDEX_PTR_CALL
  318. #undef TEX_PTR_CALL
  319. #undef DRAW_ARRAYS_CALL
  320. #undef VERTEX_PTR
  321. #undef DRAW_ARRAYS
  322. #undef NORMAL_PTR
  323. #undef COLOR_PTR
  324. #undef INDEX_PTR
  325. #undef TEX_PTR
  326. #undef SET_PTRS
  327. #undef INCR_PTRS
  328. #undef SET_NORMAL_PTR
  329. #undef SET_COLOR_PTR
  330. #undef SET_INDEX_PTR
  331. #undef SET_TEX_PTR
  332. #undef SET_VERTEX_PTR
  333. #undef INCR_NORMAL_PTR
  334. #undef INCR_COLOR_PTR
  335. #undef INCR_INDEX_PTR
  336. #undef INCR_TEX_PTR
  337. #undef INCR_VERTEX_PTR
  338. #undef INTERLEAVED_PTR_CALL
  339. #undef LOCK_ARRAYS_CALL
  340. #undef UNLOCK_ARRAYS_CALL
  341. #undef INTERLEAVED_PTR
  342. #undef SET_INTERLEAVED_PTR
  343. #undef INCR_INTERLEAVED_PTR
  344. #undef INIT_ELEMENTS_PTR
  345. #undef SET_ELEMENTS_PTR
  346. #undef INCR_ELEMENTS_PTR
  347. #undef FREE_ELEMENTS_PTR
  348.